#include<bits/stdc++.h>
using namespace std;

int T;
long long n,m,L,V;
struct Node
{
    long long d,v,a;
}node[100009];
long long p[100009];
vector<int> k[100009];
struct Nodee
{
    int l,r;
    Nodee(){}
    Nodee(int _l,int _r){l=_l;r=_r;}
};
vector<Nodee> duan;
bool cmp(Nodee x,Nodee y)
{
    return x.r<y.r;
}

int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin>>T;
    while(T--)
    {
        int ans=0;
        cin>>n>>m>>L>>V;
        for(int i=0;i<n;i++)
        {
            cin>>node[i].d>>node[i].v>>node[i].a;
        }
        for(int i=0;i<m;i++)
        {
            cin>>p[i];
        }

        long long vv,aa;
        if(n>3000||m>3000)
        {
            if(node[0].a==0)
            {
                for(int i=0;i<n;i++)
                {
                    if(node[i].v>V&&node[i].d<=p[m-1])ans++;
                }
                cout<<ans<<" ";
                if(ans==0)cout<<m<<endl;
                else cout<<m-1<<endl;
            }
            else
            {
                for(int i=0;i<n;i++)
                {
                    vv=node[i].v*node[i].v;
                    aa=2*node[i].a;
                    if(node[i].d<=p[m-1]&&vv+aa*(p[m-1]-node[i].d)>V*V)ans++;
                }
                cout<<ans<<" ";
                if(ans==0)cout<<m<<endl;
                else cout<<m-1<<endl;
            }
            continue;
        }

        duan.clear();
        bool f;
        for(int i=0;i<n;i++)
        {
            k[i].clear();
            f=0;
            vv=node[i].v*node[i].v;
            aa=2*node[i].a;
            for(int j=0;j<m;j++)
            {
                if(p[j]>=node[i].d&&vv+aa*(p[j]-node[i].d)>V*V)
                {
                    if(!f){ans++;f=1;}
                    k[i].push_back(j);
                }
            }
            if(!k[i].empty())
            {
                duan.push_back({k[i][0],k[i][k[i].size()-1]});
            }
        }
        cout<<ans<<" ";

        sort(duan.begin(),duan.end(),cmp);
        int las=-1;ans=0;
        for(int i=0;i<duan.size();i++)
        {
            if(duan[i].l>las)
            {
                ans++;
                las=duan[i].r;
            }
        }
        cout<<m-ans<<endl;
    }

    return 0;
}
